<template>
  <div class="positionDetail">
    <van-cell size="large" class="title" title-style="font-size: 40px">
      <template #title>
        <span @click="$router.back()" class="custom-title"
          ><van-icon name="arrow-left"
        /></span>
      </template>
      <template #right-icon>
        <span class="fav" @click="toFav"><van-icon name="star-o"/></span>
        <span class="share" @click="isShare = true"
          ><van-icon name="share-o"
        /></span>
      </template>
    </van-cell>
    <!-- 头部 -->
    <div class="head">
      <van-cell-group>
        <van-cell>
          <template #title>
            <div class="mytitle">
              <span class="title">{{ positionDetail.name }}</span>
              <span style="color: red;font-size: 16px">{{
                positionDetail.salary
              }}</span>
            </div>
          </template>
          <template #label>
            <div class="jobNeeds">
              <span>{{ positionDetail.city }}</span>
              <span>{{ positionDetail.experience }}</span>
              <span>{{ positionDetail.education }}</span>
            </div>
            <div class="advantage">
              <span
                v-for="(subitem, index) in positionDetail.feature"
                :key="index"
                >{{ subitem }}</span
              >
            </div>
          </template>
        </van-cell>
      </van-cell-group>
    </div>
    <!-- 内容 -->
    <div class="mainBox">
      <h3>{{ positionDetail.company.name }}</h3>
      <div class="conntentBox">
        {{ positionDetail.responsibility }}
      </div>
    </div>
    <!-- 公司连接 -->
    <div class="companyLink">
      <div class="comLogo">
        <img src="@/assets/qiye_logo.png" alt="" />
      </div>
      <div class="info">
        <div class="comName">{{ positionDetail.company.name }}</div>
        <div class="comTags">
          <span>{{ positionDetail.company.type }}</span>
          <span>{{ positionDetail.company.step }}</span>
          <span>{{ positionDetail.company.scale }}</span>
        </div>
      </div>
      <!-- 回到公司 -->
      <div @click="$router.push(`/companyDetail/${comId}`)" class="linkArrow">
        <van-icon name="arrow" />
      </div>
    </div>
    <!-- 去刷题 -->
    <div class="goQuestion">
      <van-button
        @click="$router.push('/question')"
        size="large"
        type="danger"
        round
        >去刷题</van-button
      >
    </div>
    <!-- 弹出分享 -->
    <van-popup
      v-model="isShare"
      position="bottom"
      :style="{ height: '30%' }"
      round
    >
      <div class="shareTitle">立即分享给好友</div>
      <div class="shareType">
        <ul @click="sharePop">
          <li>
            <img src="@/assets/logo.png" alt="" />
            <div class="shareT">微信</div>
          </li>
          <li>
            <img src="@/assets/qiye_logo.png" alt="" />
            <div class="shareT">微博</div>
          </li>
          <li>
            <img src="@/assets/qiye_logo.png" alt="" />
            <div class="shareT">微信</div>
          </li>
          <li>
            <img src="@/assets/qiye_logo.png" alt="" />
            <div class="shareT">微信</div>
          </li>
          <li>
            <img src="@/assets/qiye_logo.png" alt="" />
            <div class="shareT">微信</div>
          </li>
        </ul>
      </div>
      <div @click="isShare = false" class="closePop">取消</div>
    </van-popup>
  </div>
</template>

<script>
import { positionDetail } from '@/api/api'
export default {
  data () {
    return {
      isShare: false,
      positionDetail: {},
      comId: ''
    }
  },
  methods: {
    async getPositionDetail () {
      const id = this.$route.params.id
      this.comId = this.$route.query.comId
      console.log('this.comId')
      console.log(this.comId)
      const res = await positionDetail(id)
      this.positionDetail = res.data
    },
    toFav () {
      this.$toast('敬请期待')
    },
    // fen享
    sharePop () {
      this.$toast('敬请期待')
    }
  },
  created () {
    this.getPositionDetail()
  }
}
</script>

<style lang="less" scoped>
.positionDetail {
  .title {
    // height: 50px;
    font-size: 40px;
  }
  .shareTitle {
    margin: 20px 0;
    font-size: 14px;
    text-align: center;
  }
  // 头部
  .head {
    .mytitle {
      padding: 15px 0;
      display: flex;
      justify-content: space-between;
      .title {
        font-size: 24px;
        font-weight: 600;
      }
    }
    .jobNeeds {
      padding-bottom: 5px;
      span {
        margin-right: 20px;
        padding: 2px 5px;
      }
    }
    .advantage {
      span {
        margin-right: 4px;
      }
    }
  }
  // 内容
  .mainBox {
    padding: 0 15px;
    h3 {
      font-size: 24px;
      font-weight: 500;
    }
    .conntentBox {
      font-size: 16px;
    }
  }
  .shareType {
    .shareT {
      font-size: 14px;
      text-align: center;
    }
    ul {
      white-space: nowrap;
      overflow-x: auto;
      // width: 1000px;
      // font-size: 0;
      li {
        display: inline-block;
        margin: 0 20px;
        img {
          border-radius: 50%;
          width: 50px;
        }
      }
    }
  }
  // 公司连接
  .companyLink {
    display: flex;
    justify-content: space-around;
    margin-top: 10px;
    margin-bottom: 100px;
    .comLogo {
      width: 50px;
      height: 50px;
      img {
        width: 100%;
      }
    }
    .info {
      font-size: 12px;
      .comName {
        margin-top: 4px;
      }
      .comTags {
        margin-top: 8px;
        color: #b4b4bd;
        span {
          margin-right: 5px;
          padding: 2px 5px;
          border-radius: 4px;
          border: 1px solid #b4b4bd;
        }
      }
    }
    .closePop {
      width: 100%;
      padding-top: 20px;
      font-size: 20px;
      text-align: center;
      line-height: 30px;
    }
  }
  // qu shua ti
  .goQuestion {
    width: 90%;
    margin: auto;
    position: fixed;
    bottom: 20px;
    left: 20px;
  }
}
</style>
